package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.Zshipments;
import cn.gson.fengboot.model.service.ZshipmentsService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/fahuo")
public class ZshipmentsController {
    @Autowired
    ZshipmentsService service;

    //出库单新增修改
    @RequestMapping("/add")
    @ResponseBody
    public void add(@RequestBody Zshipments fh) {
        service.add(fh);
    }

    //出库单新增修改
    @RequestMapping("/List")
    @ResponseBody
    public Map<String,Object> fahuoList(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        service.fahuoList(search, search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }
}